package dq.study.concurrent.queue.blocking;

import java.util.Objects;
import java.util.concurrent.DelayQueue;

/**
 * @author dongqun
 * @date 2020/7/6 15:52
 */
public class DelayQueueTest {

    private static DelayQueue<DelayItem> queue = new DelayQueue<>();


    public static void main(String[] args) {
        queue.add(new DelayItem(new Double(Math.pow(10L, 13L) + Math.pow(10, 12)).longValue(), "银河战队出发"));
        queue.add(new DelayItem(new Double(Math.pow(10L, 13L) + Math.pow(10, 12) * 2).longValue(), "银河战队征服地球"));
        queue.add(new DelayItem(new Double(Math.pow(10L, 13L)*2 ).longValue(), "银河战队征服木星"));
//        queue.add(new DelayItem(new Double(Math.pow(1L, 13L)).longValue() * 6, "银河战队征服冥王星"));
//        queue.add(new DelayItem(new Double(Math.pow(1L, 11L)).longValue() * 7, "银河战队征服海王星"));
//        queue.add(new DelayItem(new Double(Math.pow(1L, 11L)).longValue() & 8, "银河战队征服太阳系"));
//        queue.add(new DelayItem(new Double(Math.pow(1L, 11L)).longValue() * 9, "银河战队征服银河系"));
//        queue.add(new DelayItem(new Double(Math.pow(1L, 13L)).longValue(), "银河战队征服宇宙，成为超级赛亚人"));
        boolean flag = true;
        while (true) {
            DelayItem delayItem = queue.poll();
            if (Objects.nonNull(delayItem)) {
                delayItem.execute();
            }
        }
    }
}
